#include<bits/stdc++.h>
using namespace std;
const int N=1e4+10;
int T,n,m,L,V;
int p[N];
bool ce[N][N],ces[N];
int b[N];
struct car{
    int d,v,a;
}c[N];
int ep(double x){
    int l=1,r=m,mid;
    while(l<=r){
        mid=(l+r)/2;
        if(x<=p[mid])r=mid-1;
        else l=mid+1;
    }
    return l;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        int cnt=0;
        memset(ce,0,sizeof(ce));
        memset(b,0,sizeof(b));
        memset(ces,0,sizeof(ces));
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)cin>>c[i].d>>c[i].v>>c[i].a;
        for(int i=1;i<=m;i++)cin>>p[i];
        sort(p+1,p+1+n);
        for(int i=1;i<=n;i++){
            int s,e;
            bool f=0;
            double cs=c[i].d+(V*V-c[i].v*c[i].v)*1.0/(2*c[i].a);
            if(c[i].a==0){
                if(c[i].v>V){
                    s=ep(c[i].d);e=m;
                    f=1;
                }
            }
            else if(c[i].a>0){
                s=ep(cs);e=m;
                if(p[s]==cs)s++;
                if(s<=e)f=1;
            }
            else{
                s=ep(c[i].d);e=ep(cs);
                if(cs<=p[e])e--;
                if(s<=e)f=1;
            }
            if(f)
            for(int j=s;j<=e;j++){ce[i][j]=1;b[i]++;ces[j]=1;}
            cnt+=f;
        }
        cout<<cnt<<" ";
        int tot=0;
        for(int i=1;i<=m;i++){
            bool ff=1;
            if(ces[i]!=0){
                for(int j=1;j<=n;j++){
                    if(ces[i]==0||(b[j]!=0&&b[j]-ce[j][i]==0)){
                        ff=0;break;
                    }
                }
            }
            if(ff){
                tot++;
                for(int j=1;j<=n;j++){
                   b[j]-=ce[j][i];
                }
            }
        }
        cout<<tot<<endl;
    }
    return 0;
}
